package easyzhou.com.utils.svn;

import java.io.IOException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import easyzhou.com.utils.IOUtil;

public class SVNUtil {
	public static final List<String> showLogs(String url, String userName,
			String password) {
		Runtime runtime = Runtime.getRuntime();
		List<String> list = new LinkedList<String>();
		try {
			String[] envp = { "LANG=UTF-8" };
			StringBuilder sb = new StringBuilder();
			sb.append("svn log  -v ");
			sb.append(" --username ").append(userName);
			sb.append(" --password ").append(password);
			sb.append("  ").append(url);
			java.lang.Process process = runtime.exec(sb.toString(), envp);
			String str = IOUtil.toString(process.getInputStream(), "utf-8");
			list.add(str);
			formatReuslt(str);
			String str2 = IOUtil.toString(process.getErrorStream(), "utf-8");
			list.add(str2);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public static final List<String> formatReuslt(String result) {
		if (result == null || result.isEmpty()) {
			return Collections.EMPTY_LIST;
		}
		String strs[] = result
				.split("------------------------------------------------------------------------");
		for (String string : strs) {
			System.out.println("string start");
			System.out.println(string);
		}
		return null;
	}

	public static void main(String[] args) {
		List<String> list = showLogs(
				"https://192.168.1.117/svn/jzmMobile/jzmaoMobile-3.1-broken/",
				"zc", "zc123");
		// System.out.println(list);
	}
}
